<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8"/>
    <title>用户</title>
</head>
<body>
<div class="container">

    <div sec:authorize="isAuthenticated()">
       已登录,<p>Username: <th:block sec:authentication="principal.username"></th:block></p>
    </div>
    <div sec:authorize="!isAuthenticated()">
       未登录
    </div>
</div>
</body>
</html>